<template>
        <h2>登录</h2>
        <table>
            <tr>
                <td>账号</td>
                <td><input type="text" v-model="state.username" /></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="state.password" /></td>
            </tr>
            <tr>
                <td></td>
                <td><button @click="login">登录</button></td>
            </tr>
        </table> 
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue';
import axios from 'axios';
let data = reactive({
    state: {
        username: '',
        password: ''
    }
})
let { state } = toRefs(data)
const login = () => {
    let obj = {
        username: state.value.username,
        password: state.value.password
    }
    axios({
        url: '/api/Member/MemberLogin',
        method: 'post',
        params: obj
    })
        .then(res => {
            console.log(res)
            if (res.data.data == 1) {
                alert("登录成功")
            }
            else {
                alert("登录失败")
            }
        })
        .catch(err=>{
            console.log(err)
        })
}

</script>

<style scoped></style>